import axios from 'axios'
import { getToken } from '@/utils/auth'

// const BASE_URL = 'http://192.168.33.128:10010'

const service = axios.create({
    baseURL: import.meta.env.VITE_APP_BASE_URL,
    timeout: 5000
})

service.interceptors.request.use((request: any) => {
    const token = getToken('token')
    if(token) {
        request.headers['token'] = token
    }
    // if(request.url.indexOf('login') === -1) {
        
    // }
    return request
}, 
(error: any) => {
    return Promise.reject(error)
})

service.interceptors.response.use((response: any) => {
    
    return response
}, 
(error: any) => {
    return Promise.reject(error)
})

export default service